package cn.stylefeng.guns.modular.business.model.result;

import cn.stylefeng.guns.core.OrderStatusState;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.io.Serializable;
import java.math.BigDecimal;

/**
 * <p>
 * 订单表
 * </p>
 *
 * @author jwj
 * @since 2019-07-12
 */
@Data
public class OrderResult implements Serializable {

    private static final long serialVersionUID = 1L;


    private Integer orderId;

    private String orderNo;

    private Integer ownerUserId;

    private String ownerUser;

    /**
     * 实际金额
     */
    private BigDecimal payAmount;

    /**
     * 订单金额
     */
    private BigDecimal amount;

    /**
     * 成本费率
     */
    private Float costRate;

    private Float orderRate;

    /**
     * 实际费率
     */
    private Float payRate;

    /**
     * 订单状态0，待审核，1审核成功，待结算2审核失败。3已结算
     */
    private Integer orderStatus;

    private String orderStatusName;

    /**
     * 创建时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH-mm-ss")
    private Date createTime;

    /**
     * 更新时间
     */
    private Date updateTime;

    private String createTimeStr;

    private String updateTimeStr;

    /**
     * 是否删除
     */
    private Integer deleteFlag;

    /**
     * 审核人员id
     */
    private Integer approveUserId;

    /**
     * 审核人员用户名
     */
    private String approveUser;

    /**
     * 备注
     */
    private String remark;
    /**
     * 卡号
     */
    private String cardNo;

    /**
     * 卡密
     */
    private String cardPassword;

    private Long cardCataoryId;

    private String cardCataoryName;

    private Integer cardQuotaId;

    private String cardQuotaName;

    /**
     * 提交面值
     */
    private Integer subQuota;

    /**
     * 订单面值
     */
    private Integer itemQuota;

    /**
     * 支付金额
     */
    private BigDecimal itemAmount;

    public void setOrderStatus(Integer orderStatus) {
        if (orderStatus.equals(OrderStatusState.SUBMIT.getCode())) {
            this.orderStatusName = OrderStatusState.SUBMIT.getMessage();
        } else if (orderStatus.equals(OrderStatusState.PASS.getCode())){
            this.orderStatusName = OrderStatusState.PASS.getMessage();
        } else if (orderStatus.equals(OrderStatusState.UN_PASS.getCode())) {
            this.orderStatusName = OrderStatusState.UN_PASS.getMessage();
        } else {
            this.orderStatusName = OrderStatusState.SETTLE.getMessage();
        }
        this.orderStatus = orderStatus;
    }

}
